import React, { PureComponent } from 'react';
import { connect } from 'react-redux';
import { withRouter } from 'react-router-dom';
import { actionCreators } from './store';
import styles from './style.module.scss';
// import { obtainCourseApply} from '../../.../../../../config/api'
import PlanCard  from '../../components/planCard/index';
class courseWillPlan extends PureComponent {
    render () {
        return (
            <div className={styles['course-plan']}>
                <div className={styles['plan-title']} v-if="planTableShow" click="gotoTable()">意志力鼓励计划进度 
                    <img src="https://mobuz-mp.cdn.bcebos.com/matter/willPlanTableClick.png" alt=""/>
                </div>
                {/* 课程计划卡片代码 */}
                {this.planListHtml()}
            </div>
        )
    }
    // 课程计划卡片代码
    planListHtml () {
        const {willPlan} = this.props;
        console.log(willPlan.plan,'..')
        // style="{'marginTop': planTableShow ? '0' : '30rpx'}"
        if (willPlan &&willPlan.plan) {
            return (
                <div>
                    {
                        willPlan.plan.map( (item,index) =>{
                            return (
                                <div className="plan-list" key={JSON.stringify(item)} style={{'marginBottom':'0.3rem'}}> 
                                {/* // click="gotoCourseCircumstance(item)" */}
                                    <div key={index} >
                                    {/* :starShow="planTableShow" */}
                                        <PlanCard plan={item}/>
                                    </div> 
                                </div> 
                            )
                        })
                    }
                </div>
            )
        }
    }
    componentDidMount() {
        this.props.acquireCourseWillPlan();
	}
}
const mapState = (state) => ({
    willPlan: state.courseWillPlan.willPlan,
    
});
const mapDispatch = (dispatch) => ({
	acquireCourseWillPlan() {
		// const open_id = 'obNhV46x4LBUifs9J_8oRiRkwC5w'
		const batch_id = '20190211045'
		// const student_id = '20190211045001'
		const union_id = 'oFulp0ocXjgeRLATrkVChMNhyIgk'
		dispatch(actionCreators.acquireCourseWillPlan( batch_id,union_id ));
    },
    
});
export default connect(mapState, mapDispatch)(withRouter(courseWillPlan));